package store.core;

import store.model.Vip;

import java.util.Scanner;

/**
 * 注册
 */
public class Register {


    public void register(){
        Scanner in = new Scanner(System.in);

        Store.println("注册：根据提示输入会员信息.");
        Store.print("请输入手机号：");
        String phone = in.next();
        String pwd = null;
        do {
            Store.print("请输入密码：");
            pwd = in.next();
            Store.print("请再次输入密码：");
            String pwd2 = in.next();
            if (!pwd.equals(pwd2)){
                Store.println("两次密码不一致，请重新输入！");
            } else {
                break;
            }
        } while (true);

        Store.print("请输入会员姓名：");
        String name = in.next();

        // 将会员信息保存
        Vip vip = new Vip(phone, pwd, name);
        Store.addVip(vip);

        Store.println(name + ", 恭喜您称为本店的会员！");
    }
}
